<%--
  Created by IntelliJ IDEA.
  User: 王鹏欢
  Date: 2022/3/23
  Time: 17:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    String Cookie = request.getParameter("Cookie");
%>
<%
    session.setAttribute("user",username);
    session.setAttribute("pass",password);

    if("1".equals(Cookie)){


        //创建
        Cookie cookie_username = new Cookie("username",username);
        Cookie cookie_password = new Cookie("password",password);
        //保存一天
        cookie_username.setMaxAge(60*60*24);
        cookie_password.setMaxAge(60*60*24);
        //添加
        response.addCookie(cookie_username);
        response.addCookie(cookie_password);
    }
    //重定向
    response.sendRedirect("/pages/admin/admin.jsp");
%>
</body>
</html>
